<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    namespace="Survey.Entity" assembly="Survey.Entity">
    <class name="Question" table="Question">
        <id name="ID" column="QuestionId">
            <generator class="native"></generator>
        </id>

        <property not-null="true" name="Title" />
        <property not-null="true" name="Description" />
        <property not-null="true" name="IsApproved" />
        <property not-null="true" name="ValidUntil" />

        <list name="Answers" lazy="false" cascade="all-delete-orphan" table="Answer">
            <key column="QuestionId" />
            <index column="[Index]" />

            <composite-element class="Answer">
                <parent name="Question" />
                <property not-null="true" name="ID" update="false" insert="true"
                formula="CAST([QuestionId] as varchar(15)) + '_' + CAST([Index] as varchar(10))" />
                <property not-null="true" name="Title" />
                <property not-null="true" name="Description" />
                <property not-null="true" name="Count" />
                <property not-null="true" name="Position" formula="[Index]" insert="false" update="false" />
            </composite-element>
        </list>
    </class>
</hibernate-mapping>